package com.sxhalo.fsms.quartz;

public enum AlarmCodeEnum {

	Overload(1,8, "过载报警"),  //8 OverloadAlarm
	Stall(2, 9,"堵转报警"),//9 StallAlarm
	Block(4, 10,"阻塞报警"), //10 BlockAlarm
	PhaseFailure(8, 11,"断相报警"),//11 PhaseFailureAlarm
	NegativePhase(16,12, "反相序报警"),//12 NegativePhaseAlarm
	CurrentUnbalance(32,13, "电流不平衡报警"),//13 CurrentUnbalanceAlarm
	ExternalFault(64, 14,"外部故障报警"),//14 ExternalFaultAlarm
	PTCOverheating(128,15, "PTC过热报警"),//15 PTCOverheatingAlarm
	Overvoltage(256, 16,"过电压报警"),//16 OvervoltageAlarm
	Undervoltage(512,17, "欠电压报警"),//17 UndervoltageAlarm
	Overpower(1024, 18,"过功率报警"),//18 OverpowerAlarm
	Underpower(2048, 19,"欠功率报警");




	/**
	 * 报警码
	 */
	private final Integer code;
	/**
	 * 报警字段
	 */
	private final Integer attrId;

	/**
	 * 报警信息
	 */
	private final String msg;

	public Integer getCode() {
		return code;
	}
	public Integer getAttrId() {
		return attrId;
	}
	public String getMsg() {
		return msg;
	}

	AlarmCodeEnum(Integer code, Integer attrId , String msg) {
		this.code = code;
		this.attrId = attrId;
		this.msg = msg;
	}

	/**
	 * 判断数值是否属于枚举类的值
	 * @param key
	 * @return
	 */
	public static boolean isInclude(int key){
		boolean include = false;
		for (AlarmCodeEnum e: AlarmCodeEnum.values()){
			if(e.getCode()==key){
				include = true;
				break;
			}
		}
		return include;
	}



	/**
	 * 获取某个枚举
	 * @param key
	 * @return
	 */
	public static AlarmCodeEnum getEnumByKey(int key){
		for (AlarmCodeEnum e: AlarmCodeEnum.values()){
			if(e.getCode()==key){
				return e;
			}
		}
		return null;
	}
}